clear all

*set working directory
use "Study 1 data.dta"


************
* cleaning *
************

gen PID7 = pid7
recode PID7 8=.
gen PID01=(PID7-1)/6
recode ideo5 6=3
gen ideo01=(ideo5-1)/4
gen ideo7=CC16_340a
recode ideo7 8/99=.

*controls
gen College = educ
recode College 1/4=0 5/6=1
gen Male = gender
recode Male 2=0
gen Black = 0
recode Black 0=1 if race==2
gen Hisp = 0
replace Hisp=1 if race==3
gen Asian=0
replace Asian=1 if race==4
gen Other=0
replace Other=1 if race>4
gen Age=2016-birthyr

*Trait Ownership
gen CareDiff = UHO401 - UHO407
gen FairDiff = UHO402 - UHO408
gen AuthDiff = UHO403 - UHO409
gen PatrDiff = UHO404 - UHO410
gen WholDiff = UHO405 - UHO411
gen InteDiff = UHO406 - UHO412

gen IndDiff=(CareDiff+FairDiff)/2
gen AuthPatrDiff=(AuthDiff+PatrDiff)/2

*Issue ownership
recode UHO413-UHO416 (1=-1) (2=1) (3=0)
rename UHO413 OwnPoverty
label variable OwnPoverty "Poverty"
rename UHO414 OwnEnviro
label variable OwnEnviro "Environment"
rename UHO415 OwnDefense
label variable OwnDefense "Defense"
rename UHO416 OwnCrime
label variable OwnCrime "Crime"

gen OwnDemIssues = OwnPoverty + OwnEnviro
label variable OwnDemIssues "Democratic Issues"
gen OwnRepIssues = OwnDefense + OwnCrime
label variable OwnRepIssues "Republican Issues"

label define labelown -1 "Democrats" 0 "Neither" 1 "Republicans"
label values OwnPoverty-OwnCrime labelown

*comparative party ideology
rename CC16_340g demideo
rename CC16_340h repideo
recode demideo 8/9=.
recode repideo 8/9=.
gen Partyideodiff=repideo-demideo

*political knowledge
gen knowhouse=CC16_321a
recode knowhouse 2/4=0
gen knowsenate=CC16_321b
recode knowsenate 2/4=0

gen partyplace=.
replace partyplace=0 if Partyideodiff==0
replace partyplace=0 if Partyideodiff<0
replace partyplace=0 if (demideo==. | repideo==.)
replace partyplace=1 if Partyideodiff>0 & demideo!=. & repideo!=.

gen Know3 = knowhouse+ knowsenate + partyplace


************
* analysis *
************

*models displayed in figure 1 and reported effect sizes

*enviro
ologit OwnEnviro CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store m1
margins, at(CareDiff=(-2.539 1.259)) atmeans
margins, at(FairDiff=(-2.292 1.662)) atmeans

*poverty
ologit OwnPoverty CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store m2
margins, at(CareDiff=(-2.539 1.259)) atmeans
margins, at(FairDiff=(-2.292 1.662)) atmeans

*defense
ologit OwnDefense CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store m4
margins, at(AuthDiff=(-1.676 1.864)) atmeans
margins, at(PatrDiff=(-1.57 2.106)) atmeans

*crime
ologit OwnCrime CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store m3
margins, at(AuthDiff=(-1.676 1.864)) atmeans
margins, at(PatrDiff=(-1.57 2.106)) atmeans

*figure 1
coefplot m1, bylabel(Poverty) || m2, bylabel(Environment) || m3, bylabel(Defense) || m4, bylabel(Crime) ///
xline(0, lcol(gs10)) rename(CareDiff = "Compassionate" FairDiff = "Fair-minded" AuthDiff = "Strong" PatrDiff = "Patriotic" WholDiff = "Wholesome" InteDiff = "Intelligent") ///
byopts(subtitle("Figure 1. Linking Party Issue Handling and Trait Evaluations") ///
note("Note: figure shows estimated coefficients and 95% confidence intervals from a series of ordered logit models. Controls for partisanship, ideology," "gender, race, and education are included in the models but not shown in the figure.", size(vsmall))) ///
legend(off) keep(CareDiff FairDiff AuthDiff PatrDiff InteDiff) 


*simplified models
reg OwnDemIssues IndDiff AuthPatrDiff WholDiff InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store mod1
reg OwnRepIssues IndDiff AuthPatrDiff WholDiff InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store mod2

*difference in coefs
suest mod1 mod2
test [mod1_mean]IndDiff=[mod1_mean]AuthPatrDiff
test [mod2_mean]IndDiff=[mod2_mean]AuthPatrDiff
test [mod1_mean]IndDiff=[mod2_mean]IndDiff
test [mod1_mean]AuthPatrDiff=[mod2_mean]AuthPatrDiff
test [mod1_mean]InteDiff=[mod2_mean]InteDiff

** full test of differences in coefficients (appendix)

*comparing trait coefficients within models
ologit OwnEnviro CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
test CareDiff=AuthDiff
test CareDiff=PatrDiff
test FairDiff=AuthDiff
test FairDiff=PatrDiff
ologit OwnPoverty CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
test CareDiff=AuthDiff
test CareDiff=PatrDiff
test FairDiff=AuthDiff
test FairDiff=PatrDiff
ologit OwnCrime CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
test CareDiff=AuthDiff
test CareDiff=PatrDiff
test FairDiff=AuthDiff
test FairDiff=PatrDiff
ologit OwnDefense CareDiff-InteDiff PID7 ideo5 College Male Black Hisp Asian Other
test CareDiff=AuthDiff
test CareDiff=PatrDiff
test FairDiff=AuthDiff
test FairDiff=PatrDiff

*comparing trait coefficients across models
suest m1 m2 m3 m4
test [m1_OwnEnviro]CareDiff=[m4_OwnDefense]CareDiff
test [m1_OwnEnviro]CareDiff=[m3_OwnCrime]CareDiff
test [m2_OwnPoverty]CareDiff=[m4_OwnDefense]CareDiff
test [m2_OwnPoverty]CareDiff=[m3_OwnCrime]CareDiff

test [m1_OwnEnviro]FairDiff=[m4_OwnDefense]FairDiff
test [m1_OwnEnviro]FairDiff=[m3_OwnCrime]FairDiff
test [m2_OwnPoverty]FairDiff=[m4_OwnDefense]FairDiff
test [m2_OwnPoverty]FairDiff=[m3_OwnCrime]FairDiff

test [m1_OwnEnviro]AuthDiff=[m4_OwnDefense]AuthDiff
test [m1_OwnEnviro]AuthDiff=[m3_OwnCrime]AuthDiff
test [m2_OwnPoverty]AuthDiff=[m4_OwnDefense]AuthDiff
test [m2_OwnPoverty]AuthDiff=[m3_OwnCrime]AuthDiff

test [m1_OwnEnviro]PatrDiff=[m4_OwnDefense]PatrDiff
test [m1_OwnEnviro]PatrDiff=[m3_OwnCrime]PatrDiff
test [m2_OwnPoverty]PatrDiff=[m4_OwnDefense]PatrDiff
test [m2_OwnPoverty]PatrDiff=[m3_OwnCrime]PatrDiff


*testing ideology as an alternative explanation
ologit OwnEnviro CareDiff-InteDiff Partyideodiff PID7 ideo5 College Male Black Hisp Asian Other
ologit OwnPoverty CareDiff-InteDiff Partyideodiff PID7 ideo5 College Male Black Hisp Asian Other
ologit OwnDefense CareDiff-InteDiff Partyideodiff PID7 ideo5 College Male Black Hisp Asian Other
ologit OwnCrime CareDiff-InteDiff Partyideodiff PID7 ideo5 College Male Black Hisp Asian Other


*are issue-trait links limited to politically aware?
reg OwnDemIssues c.IndDiff##c.Know3 c.AuthPatrDiff##c.Know3 WholDiff InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store int1
margins, dydx(IndDiff) at(Know3=(0 1 2 3))
marginsplot, ylab(-.4(.4).8) yline(0) recast(line) recastci(rarea) ci1opts(fcolor(sky%30)) ///
	xtitle("Political Knowledge") xsc(titlegap(2)) ytitle("Effect of C-F") ///
	subtitle("Democrat-Owned Issues") title("") saving(dem_ind.gph, replace)
margins, dydx(AuthPatrDiff) at(Know3=(0 1 2 3))
marginsplot, ylab(-.4(.4).8) yline(0) recast(line) recastci(rarea) ci1opts(fcolor(sky%30)) ///
	xtitle("Political Knowledge") xsc(titlegap(2)) ytitle("Effect of S-P") ///
	subtitle("Democrat-Owned Issues") title("") saving(dem_bind.gph, replace)
	
reg OwnRepIssues c.IndDiff##c.Know3 c.AuthPatrDiff##c.Know3 WholDiff InteDiff PID7 ideo5 College Male Black Hisp Asian Other
est store int2
margins, dydx(IndDiff) at(Know3=(0 1 2 3))
marginsplot, ylab(-.4(.4).8) yline(0) recast(line) recastci(rarea) ci1opts(fcolor(cranberry%30)) ///
	xtitle("Political Knowledge") xsc(titlegap(2)) ytitle("Effect of C-F") ///
	subtitle("Republican-Owned Issues") title("") saving(rep_ind.gph, replace)
margins, dydx(AuthPatrDiff) at(Know3=(0 1 2 3))
marginsplot, ylab(-.4(.4).8) yline(0) recast(line) recastci(rarea) ci1opts(fcolor(cranberry%30)) ///
	xtitle("Political Knowledge") xsc(titlegap(2)) ytitle("Effect of S-P") ///
	subtitle("Republican-Owned Issues") title("") saving(rep_bind.gph, replace)

graph combine dem_ind.gph dem_bind.gph rep_ind.gph rep_bind.gph, ///
	subtitle("Figure 2. Issues and Traits Are Linked Among the Least Politically Knowledgeable") ///
	note("Note: figure plots the effect of relative party trait perceptions on issue competence ratings across levels of political knowledge. C-F = average of" "compassionate and fair-minded traits. S-P = average of strong and patriotic traits.", size(vsmall))

